package cn.com.taiji.pos.service.impl;

import cn.com.taiji.pos.entity.SystemPosMachine;
import cn.com.taiji.pos.mapper.SystemPosMachineMapper;
import cn.com.taiji.pos.service.ISystemPosMachineService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * <p>
 * POS机信息 服务实现类
 * </p>
 *
 * @author
 * @since 2021-03-01
 */
@Service
public class SystemPosMachineServiceImpl extends ServiceImpl<SystemPosMachineMapper, SystemPosMachine> implements ISystemPosMachineService {
    @Resource
    private SystemPosMachineMapper systemPosMachineMapper;


    @Override
    public SystemPosMachine findByPhysicalCode(String physicalCode) {
        QueryWrapper<SystemPosMachine> SystemPosMachineWrapper = new QueryWrapper<>();
        SystemPosMachineWrapper.eq("PHYSICAL_CODE", physicalCode);
        return  this.getOne(SystemPosMachineWrapper,false);

    }

    //   查询包含项目和餐厅信息
    @Override
    public SystemPosMachine findByPhysicalCode2(String physicalCode) {
        return systemPosMachineMapper.systemPosMachineMapper(physicalCode);
    }

    @Override
    public void updateMoney(SystemPosMachine systemPosMachine, String consumptionAmount) {
        systemPosMachine.setMoney(new BigDecimal(systemPosMachine.getMoney().doubleValue() + Double.parseDouble(consumptionAmount)));
        systemPosMachineMapper.updateById(systemPosMachine);
    }
}
